<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//创建一个动物类为父类
			class Animal {
				type = "动物";
				//构造方法体
				constructor(type) {
					this.type = type;
				}
				//爱吃东西的方法
				eat() {
					console.log(this.type + "爱吃东西");
				}
			}
			//创建一个小鸡类为子类，继承父类
			class Chicken extends Animal {
				constructor() {
					//调用父类的方法
					super("小鸡",);
					
				}
				//重写爱吃东西的方法
				eat() {
					console.log(this.type + "爱吃米");
				}
			}
			//实例化
			var chicken = new Chicken();
			chicken.eat();
			//创建一个小羊为子类继承父类
			class Sheep extends Animal {
				constructor() {
					super("小羊");
				}
				eat() {
					console.log(this.type + "爱吃酱肘子");
				}
			}
			var sheep = new Sheep();
			sheep.eat();
			//创建一个小熊类为子类来继承父类
			class Bear extends Animal {
				constructor(name) {
					super("小熊");
					this.name = name;
				}
				eat() {
					console.log(this.type + this.name + "爱吃蜂蜜");
				}
			}
			var bear = new Bear("维尼");
			bear.eat();
		</script>
	</body>
</html>
